package org.otherworld.frame.filebrowser;

import java.awt.BorderLayout;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Rectangle;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class FileBrowser extends JFrame {
	private static final long serialVersionUID = 1L;
	private FilePanel left_panel;
	private FilePanel right_panel;
	private JPanel menu;
	private JPanel fileField;
	public FileBrowser() {
		int windowWidth = 1024;
		int windowHeight = 768;
		this.setSize(windowWidth, windowHeight);
		this.setLayout(new BorderLayout());
		
		menu = new JPanel();
		menu.setLayout(new BorderLayout());
		menu.setName("menufield");
		this.initMenu(menu);
		this.add(menu,BorderLayout.NORTH);
		
		fileField = new JPanel();
		fileField.setLayout(null);
		fileField.setName("filefield");
		this.initLeftPanel(fileField);
		this.initRightPanel(fileField);
		this.add(fileField,BorderLayout.CENTER);
		
		
		this.setVisible(true);
		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	}

	private void initMenu(JPanel menu) {
		JMenuBar menubar = new JMenuBar();
		JMenu file = new JMenu("Test Menu");
		JMenuItem test = new JMenuItem();
		test.setText("Test");
		file.add(test);
		menubar.add(file);
		menu.add(menubar,BorderLayout.NORTH);
	}

	private void initLeftPanel(JPanel panel) {
		JLabel label = new JLabel("Left panel");
		label.setLocation(10,20);
		label.setSize(70,20);
		label.setVisible(true);
		panel.add(label);
		
		this.left_panel = new FilePanel(this,panel);
		left_panel.setTreeName("left");
		left_panel.setComponentName("left_component");
		left_panel.renderTree();
		left_panel.setSize(480, 500);
		left_panel.setLocation(10,50);
		left_panel.setName("leftpanelfield");
		panel.add(left_panel);
	}

	private void initRightPanel(JPanel panel) {
		JLabel label = new JLabel("Right panel");
		label.setLocation(510,20);
		label.setSize(70,20);
		label.setVisible(true);
		panel.add(label);
		this.right_panel = new FilePanel(this,panel);
		right_panel.setTreeName("right");
		right_panel.setComponentName("right_component");
		right_panel.renderTree();
		right_panel.setSize(480, 500);
		right_panel.setLocation(510,50);
		right_panel.setName("rightpanelfield");
		panel.add(right_panel);
	}

	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				new FileBrowser();
			}
		});

	}
}
